#pragma once
#include"BRTree.h"
#include<iostream>
using namespace std;
namespace jz
{
	template<class K,class V>
	class map {
	public:
		struct Map_KeyofT {
			const K& operator()(const pair<K, V>& key)
			{
				return key.first;
			}
		};
	public:

		typedef typename RBTree<K, pair<const K, V>, Map_KeyofT>::iterator iterator;
		typedef typename RBTree<K, pair<const K,V>, Map_KeyofT>::const_iterator const_iterator;
		iterator begin()
		{
			return _m.begin();
		}
		iterator end()
		{
			return _m.end();
		}
		pair<iterator,bool> Insert(const pair<K, V>& key)
		{
			return _m.insert(key);
		}
		iterator Find(const pair<K, V>& key)
		{
			return _m.find(key);
		}
		bool Is_balance()
		{
			return _m.IsBalance();
		}
		size_t node_size()
		{
			return _m.Size();
		}
		int tree_height()
		{
			return _m.height();
		}
	private:
		RBTree<K, pair<const K,V> , Map_KeyofT> _m;
	};

	void test_map1()
	{
		map<int, int> m;
		int a[] = { 4, 2, 6, 1, 3, 5,7,8,9,10,11,12,13,14,16,17,181,19,111,123,243,234,456,567,678,697 };
		for (auto e : a)
		{
			m.Insert(make_pair(e, e));
		}
		int n = m.node_size();
		cout << "node_size:" << n << endl;
		//bool flage = m.Is_balance();
		//cout << "is_balance: " << flage << endl;
		//int height = m.tree_height();
		//cout << "tree_height: " << height << endl;
		map<int, int>::iterator it = m.begin();
		while (it != m.end())
		{
			//it->first += 100;
			it->second += 100;

			cout << it->first << ":" << it->second << endl;
			++it;
		}
		cout << endl;
	}
}
